package com.pda.xinma.adapter;

import android.view.View;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.listener.OnItemClickListener;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.pda.xinma.R;
import com.pda.xinma.bean.ManifestListBean;
import com.wangshen.base.ui.mvp.base.adapter.BaseAdapter;

import java.util.ArrayList;
import java.util.List;

public class InventoryOneAdapter extends BaseAdapter<ManifestListBean> {
    OnClickItem onClickItem;
    public InventoryOneAdapter(int layoutResId, @Nullable List<ManifestListBean> data) {
        super(layoutResId, data);
    }

    public OnClickItem getOnClickItem() {
        return onClickItem;
    }

    public void setOnClickItem(OnClickItem onClickItem) {
        this.onClickItem = onClickItem;
    }

    @Override
    protected void convert(BaseViewHolder helper, ManifestListBean item) {
        super.convert(helper, item);
        helper.setText(R.id.tv_storageBin,item.getStorageBinId());
        helper.setText(R.id.tv_warehouseName,item.getWarehouseName());
        RecyclerView recyclerView=helper.getView(R.id.rv_list);
        InventoryAdapter inventoryAdapter = new InventoryAdapter(R.layout.item_inventory, item.getDetails());
        recyclerView.setAdapter(inventoryAdapter);
        inventoryAdapter.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(@NonNull BaseQuickAdapter<?, ?> adapter, @NonNull View view, int position) {
                if (onClickItem != null){
                    onClickItem.onItemClick(inventoryAdapter.getData().get(position),item.getStorageBinId());
                }
            }
        });
    }
    public  interface OnClickItem{
        void onItemClick( ManifestListBean.DetailsBean detailsBean,String staoid);
    }
}
